package com.industrial.premu.controller;

import com.industrial.common.core.web.controller.BaseController;
import com.industrial.common.core.web.domain.AjaxResult;
import com.industrial.premu.dto.PreMuEvaluationDataSubmissionDto;
import com.industrial.premu.service.IPreMuEvaluationDataSubmissionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(tags = "亩产评价数据提报控制层")
@RequestMapping("/evaluation/dataSubmission")
public class PreMuEvaluationDataSubmissionController extends BaseController {

    @Autowired
    private IPreMuEvaluationDataSubmissionService preMuEvaluationDataSubmissionService;

    @ApiOperation("提报亩产评价数据")
    @PostMapping("/submit")
    public AjaxResult submitData(@RequestBody PreMuEvaluationDataSubmissionDto dto) {
        return preMuEvaluationDataSubmissionService.submitData(dto);
    }

    @ApiOperation("判断当前企业是否已提报数据")
    @GetMapping("/getFlag")
    public AjaxResult getFlag() {
        return AjaxResult.success(preMuEvaluationDataSubmissionService.getFlag());
    }

    @ApiOperation("根据当前登录用户查询其企业信息")
    @GetMapping("/getCompanyInfo")
    public AjaxResult getCompanyInfo() {
        return AjaxResult.success(preMuEvaluationDataSubmissionService.getCompanyInfo());
    }

    @ApiOperation("查询当前企业历年数据提报记录")
    @GetMapping("/page")
    public AjaxResult page(PreMuEvaluationDataSubmissionDto dto) {
        return AjaxResult.success(preMuEvaluationDataSubmissionService.page(dto));
    }

    @ApiOperation("查询数据提报详情")
    @GetMapping("/getDataSubmissionById")
    public AjaxResult getDataSubmissionById(@RequestParam("id") String id) {
        return AjaxResult.success(preMuEvaluationDataSubmissionService.getDataSubmissionById(id));
    }

    @ApiOperation("重新提报亩产评价数据")
    @PutMapping("/resubmit")
    public AjaxResult resubmitData(@RequestBody PreMuEvaluationDataSubmissionDto dto) {
        return preMuEvaluationDataSubmissionService.resubmitData(dto);
    }

    @ApiOperation("查询数据提报列表（后台）")
    @GetMapping("/backend/page")
    public AjaxResult pageBackend(PreMuEvaluationDataSubmissionDto dto) {
        return AjaxResult.success(preMuEvaluationDataSubmissionService.pageBackend(dto));
    }

    @ApiOperation("批量审批提报的数据")
    @PutMapping("/approvalBatch")
    public AjaxResult approvalDataBatch(@RequestBody PreMuEvaluationDataSubmissionDto dto) {
        return preMuEvaluationDataSubmissionService.approvalDataBatch(dto);
    }
}
